﻿using UnityEngine;
using System.Collections;

public class EnemyMovement : MonoBehaviour 
{
  private float height_;

  void Start()
  {
    Transform spriteTrans = GameObjectHelper.Find<Transform>(transform, "Sprite", false);
    height_ = spriteTrans.GetComponent<SpriteRenderer>().sprite.rect.height *spriteTrans.localScale.y;
  }
  void Update()
  {
    transform.Translate(Vector3.down * Time.deltaTime * GlobalSetting.EnemyMoveSpeed);
    Vector2 screenPos = Camera.main.WorldToScreenPoint(transform.position);
    if (screenPos.y + height_ < 0)
    {
      Debug.Log("Leave");
      EnemyManager.Instance.leave(gameObject);
    }
  }
}
